require("../util.js");
require("../component/components.js");
require("../../jsMt/util.js");
var userInfo=JSON.parse(sessionStorage.getItem("userInfo"));
if(!userInfo){
    location.href="/loginIndex"
}
var vm = new Vue({
    el:"#mySell",
    data:{
        name:"",
        type:"",
        loadFlag:false,
        value:1,
        list:{
            loginUid:userInfo.id,
            order:1,
            pageNumber:1
        },
        seller:{},
        // isScreen:"",
        noticeList:{},//列表
        noticeList1:[],
        noticeList2:[]
    },
    mounted:function(){
        this.searchObject = this.getQueryStringArgs();
        this.type=this.searchObject&&this.searchObject.type;
        this.myseller();
        this.myList();
    },
    methods:{
        //后退
        getBack:function(){
            location.href="/happyi";
            // history.go(-1);
        },
        bgimg:function(url){
            url = url?url:"";
            return {
                "background-image":'url("'+url+'"),url("")'
            }
        },
        /*获取查询字符对象*/
        getQueryStringArgs: function () {
            //取得查询字符串并去掉开头的问号
            var qs = (location.search.length > 0 ? location.search.substring(1) : ""),
                args = {},
                items = qs.length ? qs.split("&") : [],
                item = null,
                name = null,
                value = null,
                len = items.length;
            for (var i = 0; i < len; i++) {
                item = items[i].split("=");
                name = item[0];
                value = item[1];
                if (name.length) {
                    args[name] = value;
                }
            }
            return args;
        },
        //我的售卖
        myseller:function(){
            var that=this;
            var data={
                loginUid:that.list.loginUid
            };
            this.ajax({url:"/happyi/myseller",data:data,dataType:"json",method:"post"},function(b){
                if(b.json.code==0&&b.json.data){
                    that.seller=b.json.data;
                }else{
                    vm.$refs.prompt.toast("获取信息失败！");
                }
            });
        },
        //获取列表
        myList:function(){
            var that=this;
            this.ajax({url:"/happyi/myUpperProduct",data:that.list,dataType:"json",method:"post"},function(b){
                if(b.json.code==0&&b.json.data){
                    that.noticeList=b.json.data;
                    that.noticeList1=that.noticeList.list;
                    if(that.noticeList.pageNumber>1){
                        if(that.noticeList.list.length>0) {
                            that.noticeList2 = that.noticeList2.concat(b.json.data.list);
                        }
                    }else{
                        that.noticeList2=that.noticeList1;
                    }
                    console.log(that.noticeList2);
                    vm.loadFlag=false;
                }else{
                    that.noticeList={};
                    that.noticeList1=[];
                    that.noticeList2=[];
                    vm.$refs.prompt.toast("获取列表失败！");
                }
            });

        },
        getNext:function(num,id){
            if(num==1){
                location.href="/happyi/myCommodity"
            }else if(num==2){
                location.href="/happyi/orderAdmin"
            }else if(num==3){
                location.href="/userGoodsInfo?productId="+id
            }
        }
    }
});